package cn.edu.seu.cose.qol.ws.resource.util.adapter;

import java.util.Collection;
import java.util.LinkedList;

import cn.edu.seu.cose.qol.model.dto.admin.AdminInstance;
import cn.edu.seu.cose.qol.model.dto.admin.Admins;
import cn.edu.seu.cose.qol.model.po.account.AdminAccount;


public class AdminsAdapter {
	
	private static AdminsAdapter _instance;
	
	public static AdminsAdapter getInstance() {
		if (_instance == null) {
			_instance = new AdminsAdapter();
		}
		
		return _instance;
	}
	
	protected AdminsAdapter() {}
	
	public Admins adapt(Collection<AdminAccount> adminAccounts) {
		Admins admins = new Admins();
		
		LinkedList<AdminInstance> adminList = new LinkedList<AdminInstance>();
		AdminAdapter adminAdapter = AdminAdapter.getInstance();
		for (AdminAccount adminAccount: adminAccounts) {
			AdminInstance adminInstance = adminAdapter.adapt(adminAccount);
			adminList.add(adminInstance);
		}
		
		admins.setAdmins(adminList.toArray(new AdminInstance[0]));
		return admins;
	}

}
